﻿using Mapster;
using SmartAgricultureService.Tables;

namespace SmartAgricultureService.Models.Tables
{
    public class LogInfo
    {
        public string Id { get; set; }
        public string DeviceId { get; set; }
        public string DeviceName { get; set; }
        public string Message { get; set; }
        public DateTime CreateTime { get; set; }
        public static TypeAdapterConfig GetAdapterConfig()
        {
            return new TypeAdapterConfig().NewConfig<LogEntry, LogInfo>()
                .Map(dest => dest.Id, src => src.Id)
                .Map(dest => dest.DeviceId, src => src.DeviceId)
                .Map(dest => dest.Message, src => src.Message)
                .Map(dest => dest.CreateTime, src => src.CreateDate)
                .Map(dest => dest.DeviceName, src => src.Device.Name, cond => cond.Device != null)
                .Config;
        }
    }
}